<HTML>
<!-- =====================================================================

  File:      popularitems.htm for Adventure Works Cycles Storefront Sample
  Summary:   Self-documentation for application
  Date:	     June 16, 2003

=====================================================================

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= -->
    <head>
        <title>Adventure Works Cycles Store Documentation</title>
        <link rel="stylesheet" href="style.css">
    </head>
    <BODY>
        <h1>
            PopularItems User Control
        </h1>
        <P>
            <b>Description:&nbsp;</b>The PopularItems user control displays a list of the 
            top 5 most popular items purchased from Adventure Works Cycles, and enables users to easily 
            navigate off to read details about each one.
        </P>
        <p>
            <A href="UserControls.htm"><STRONG>Click here to learn more about what user controls 
                    are and how they are used within ASP.NET Web Applications</STRONG></A>
        </p>
        <p>
            <strong>Implementation Notes:&nbsp;</strong>
        &nbsp;This control is used on the Adventure Works Cycles application home page.
        <p>
            The PopularItems user control logic is encapsulated entirely within its&nbsp;<strong>Page_Load</strong>
        &nbsp;event handler.&nbsp; This event handler is called when a page containing 
        the user control is accessed by a browser client.&nbsp;
        <p>
            <strong>Page_Load Event Handler:&nbsp;</strong> &nbsp;The Page_Load event 
            handler creates an instance of the ProductDB class and calls its 
            GetMostPopularProductsOfWeek method, passing it the product ID. This method 
            internally uses the <a href="usp_ProductsMostPopular.htm">usp_ProductsMostPopular</a>
        stored procedure to fetch the product&nbsp;information from the Adventure Works Cycles 
        database.&nbsp;
        <p>
        The product collection is displayed using a templated &lt;asp:Repeater&gt; 
        server control.&nbsp; As used in this user control, the Repeater server control 
        contains three user-defined templates -- HeaderTemplate, ItemTemplate and 
        FooterTemplate -- that describe how the list should look.&nbsp; The 
        ItemTemplate defines how the bound data is displayed; the HeaderTemplate 
        defines HTML that is emitted at the beginning of the list;&nbsp;and the 
        FooterTemplate defines HTML that is emitted at the end of the list.
        <p>
            The data values returned from the ProductsDB.GetMostPopularProductsOfWeek() 
            method are populated into the Repeater by setting its Datasource property, and 
            then calling its&nbsp;<strong>DataBind()</strong>
        &nbsp;method.&nbsp; When DataBind() is called, the Repeater will render its 
        HeaderTemplate, then iterate over the DataSource and render a copy of the 
        ItemTemplate for each row, populating it data from the row.&nbsp; 
        Finally,&nbsp;the Repeater&nbsp;will render its FooterTemplate.&nbsp;
        <p>
            <b>Peformance Notes:&nbsp;</b>
            <ul>
                <li>
                    The PopularItems user control support partial page output caching 
                    to outputcache its results at 1 day 
                    intervals. This enables the application to avoid having to read the 
                    database on each request to a page containing this user control 
                    (dramatically improving performance). 
                </li>
            </ul>
        <p>
        </p>
    </BODY>
</HTML>
